//
// Created by wenyaxi on 24-10-30.
//
#include <common.h>

class Solution {
public:
    ListNode *getIntersectionNode(ListNode *headA, ListNode *headB) {
        ListNode *a = headA, *b = headB;
        while(headA && headB) {
            headA=headA->next;
            headB=headB->next;
        }
        while(headA) {
            headA=headA->next;
            a=a->next;
        }
        while(headB) {
            headB=headB->next;
            b=b->next;
        }
        while(a!=b) {
            a=a->next;
            b=b->next;
        }
        return a;
    }
};

int main(int argc, char *argv[]) {
    return 0;
}
